package com.wbcs.system.component.application.report.configbean.editablereport;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.wbcs.exception.WbcsConfigLoadingException;
import com.wbcs.util.Tools;

public abstract class AbsJavaEditActionBean extends AbsEditActionBean
{
    private static Log log=LogFactory.getLog(AbsJavaEditActionBean.class);
    
    public AbsJavaEditActionBean(EditActionGroupBean ownerGroupBean)
    {
        super(ownerGroupBean);
    }

    public AbsJavaEditActionBean()
    {
        super(null);
    }
    
    @Override
	public void setOwnerGroupBean(EditActionGroupBean ownerGroupBean)
    {
        this.ownerGroupBean=ownerGroupBean;
    }
    
    @Override
	public void parseActionscript(String reportTypeKey,String actionscript)
    {
        
        if(actionscript==null||actionscript.trim().equals("")) return;
        if(this.ownerGroupBean.getOwnerUpdateBean().isAutoReportdata()
                &&!(this.ownerGroupBean.getOwnerUpdateBean() instanceof EditableReportDeleteDataBean))
        {
            List<String> lstParamsTmp=Tools.parseStringToList(actionscript,',','\'');
            for(String paramTmp:lstParamsTmp)
            {
                if(paramTmp==null||paramTmp.trim().equals("")) continue;
                if(!Tools.isDefineKey("@",paramTmp))
                {
                    throw new WbcsConfigLoadingException("加载报表"+this.ownerGroupBean.getOwnerUpdateBean().getOwner().getReportBean().getPath()
                            +"失败，配置的更新数据JAVA类中指定的参数"+paramTmp+"不合法，对于JAVA类，只能在参数列表中指定@{column}/@{column__old}两种之一的格式，如果要传入其它类型的参数，请配置相应的<param/>");
                }
                createParamBeanByColbean(Tools.getRealKeyByDefine("@",paramTmp),reportTypeKey,true,true);
            }
        }else
        {
            log.warn("报表"+this.ownerGroupBean.getOwnerUpdateBean().getOwner().getReportBean().getPath()+"的<delete/>或<button/>中配置的JAVA类不需要在括号中指定"
                    +actionscript+"参数，在这里的指定没有任何作用，可以在<params/>中定义要传入JAVA类中的参数");
        }
    }

    public void beginTransaction()
    {

    }

    public void commitTransaction()
    {

    }

    public void rollbackTransaction()
    {

    }

}
